﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;

namespace WatiNCF.Automater.Controls
{
    public partial class EnumEntryControl : BaseDataEntryControl
    {

        public EnumEntryControl()
        {
            InitializeComponent();
        }

        public override void SetName(string name)
        {
            this.NameLabel.Text = name;
            this.ValueComboBox.DataSource = Enum.GetNames(this.Adapter.GetInfoType());
            
            object value = this.Adapter.GetValue();
            if(value != null)
            {
                this.ValueComboBox.SelectedItem = value.ToString();
            }
        }

        public override object GetValue()
        {
            return this.Adapter.SetValue(Enum.Parse(this.Adapter.GetInfoType(), this.ValueComboBox.Text, true));
        }

        public override void SetFocus()
        {
            this.ValueComboBox.Focus();
        }
    }
}
